package com.sxkf.template.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxkf.core.api.vo.R;
import com.sxkf.template.entity.Feedback;
import com.sxkf.template.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.util.CheckEmptyUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-12-27 10:23:39
 */
@Api(tags = "功能反馈")
@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    @Resource
    private FeedbackService feedbackService;

    @ApiOperation("创建")
    @PostMapping("/createFeedback")
    public R<Boolean> createFeedback(@RequestBody Feedback feedback) {
        return R.success(feedbackService.save(feedback));
    }

    @ApiOperation("更新")
    @PostMapping("/updateFeedback")
    public R<Boolean> updateFeedback(@RequestBody Feedback feedback) {
        return R.success(feedbackService.updateById(feedback));
    }

    @ApiOperation("删除")
    @PostMapping("/deleteFeedback")
    public R<Boolean> deleteFeedback(@RequestParam String id) {
        return R.success(feedbackService.removeById(id));
    }

    @ApiOperation("查询")
    @GetMapping("/listFeedback")
    public R<List<Feedback>> listFeedback() {
        return R.success(feedbackService.list(new LambdaQueryWrapper<Feedback>()
                .orderByDesc(Feedback::getCreateTime)));
    }
}
